<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="index.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="favicon.ico">
<link rel="Shortcut Icon" href="favicon.ico" />

<title>主页</title>
<meta name="keywords" content="耶回收">
<meta name="description" content="耶回收">

</head>
<body>
	<!--_表格--开始-->
	<section class="Hui-article-box" style="overflow: auto"> <nav
		class="breadcrumb"> <i class="Hui-iconfont">&#xe67f;</i> 首页 <span
		class="c-gray en">&gt;</span> 轮播管理 <span class="c-gray en">&gt;</span>
	轮播信息管理 <span class="c-gray en">&gt;</span> 轮播修改 </nav>

	<div class="page-container">
		<form action="updateLunBo" method="post" class="form form-horizontal"
			id="form-back-add">
				<input type="hidden" value="${lb.lbid}" name="lbid">
				<input type="hidden" value="${lb.lbcreated}" name="lbcreated">
				<div class="row cl">
					<label style="margin-top: 50px"
						class="form-label col-xs-4 col-sm-3">轮播主题：</label>
					<div class="formControls col-xs-8 col-sm-6">
						<input type="text" class="input-text" style="margin-top: 50px"
							value="${lb.lbname}" data-msg-required="新闻主题不能为空"
							data-rule-required="true" placeholder="" id="" name="lbname">
					</div>
				</div>

				<div class="row cl">
					<label style="margin-top: 30px"
						class="form-label col-xs-4 col-sm-3">轮播链接：</label>
					<div class="formControls col-xs-8 col-sm-6">
						<input type="text" class="input-text" style="margin-top: 30px"
							value="${lb.lblink}" data-msg-required="新闻链接不能为空"
							data-rule-required="true" data-msg-url="链接格式不正确 请以 http://" url="true"
							placeholder="" id="" name="lblink">
					</div>
				</div>

				<div class="row cl">
					<label style="margin-top: 50px"
						class="form-label col-xs-4 col-sm-3">轮播图片：</label>
					<div class="formControls col-xs-8 col-sm-6">
						<input type="hidden" id="lbimage" value="${lb.lbimage}" name="lbimage">
						<input type="file" class="" style="margin-top: 50px" value="" id="img">
					<span>
						<img src="${lb.lbimage}" id="showimg" height="100px" width="100px"
							style="margin-right: 100px; margin-top: 50px"></span> <input
							type="button" class="btn btn-primary radius"
							style="margin-top: 50px" onclick="imgupload()" value="修改">
					</div>
				</div>

				<div class="row cl" style="margin-top: 50px">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<button class="btn btn-primary radius" type="submit">
							<i class="Hui-iconfont">&#xe632;</i>修改
						</button>
					</div>
				</div>
		</form>
	</div>

	</section>

</body>
<script
	src="<%=basePath%>lib/jquery.validation/1.14.0/jquery.validate.js"
	type="text/javascript"></script>
<script type="text/javascript">
	function imgupload() {
		var animateimg = $("#img").val(); //获取上传的图片名 带//
		var imgarr = animateimg.split('\\'); //分割 
		var myimg = imgarr[imgarr.length - 1]; //去掉 // 获取图片名 
		var houzui = myimg.lastIndexOf('.'); //获取 . 出现的位置
		var ext = myimg.substring(houzui, myimg.length).toUpperCase(); //切割 . 获取文件后缀 
		var file = $("#img").get(0).files[0]; //获取上传的文件
		var form = new FormData();
		form.append("ext", ext);
		form.append("file", file);
		if (ext != '.PNG' && ext != '.GIF' && ext != '.JPG' && ext != '.JPEG'
				&& ext != '.BMP') {
			parent.layer.msg('文件类型错误,请上传图片类型');
			return false;
		} else {
			// var data = new FormData($('#form1')[0]);
			$.ajax({
				url : "imgupdate",
				type : 'POST',
				data : form,
				dataType : 'JSON',
				processData : false, // 注意：让jQuery不要处理数据
				contentType : false, // 注意：让jQuery不要设置contentType
				success : function(ret) {
					$("#lbimage").val(ret.filepath);
					$("#showimg").attr('src', ret.filepath);
					layer.msg('上传成功');
					/* if(ret=="1"){  
					    var result = '';  
					    var result1 = '';  
					    // $("#show").attr('value',+ ret['f'] +);  
					    result += '<img src="' + '__ROAD__' + ret['f']  + '" width="100">';  
					    result1 += '<input value="' + ret['f']  + '" name="user_headimg" style="display:none;">';  
					    $('#result').html(result);  
					    $('#show').html(result1);  
					    layer.msg('上传成功');  
					}else{    
					    layer.msg('上传失败');  
					} */
				}
			});
		}

	}
	//表单验证
	$(function() {

		$("#form-back-add").validate({
		//做完表单验证后的  ajax后台数据验证 如果不满足条件 则禁止表单的提交
		/* submitHandler: function(form){
		 return checktitle();
		 //发出ajax请求 根据回调函数的返回值 来判断checkBackitemExsit()的返回值；
		
		} */

		});

	});
</script>
</html>